package org.yenn.pattern.aliyun.j2ee.transferobject;

import org.junit.Test;

import static org.junit.Assert.*;

/**
 * @Author: yerenyun
 * @Description:步骤 3
 * 使用 StudentBO 来演示传输对象设计模式。
 */
public class TransferObjectPatternDemo {
    /**
     * 步骤 4
     * 验证输出。
     *
     * Student: [RollNo : 0, Name : Robert ]
     * Student: [RollNo : 1, Name : John ]
     * Student: Roll No 0, updated in the database
     * Student: [RollNo : 0, Name : Michael ]
     */
    @Test
    public void getAllStudents() {
        StudentBO studentBusinessObject = new StudentBO();

        //输出所有的学生
        for (StudentVO student : studentBusinessObject.getAllStudents()) {
            System.out.println(student);
        }

        //更新学生
        StudentVO student = studentBusinessObject.getAllStudents().get(0);
        student.setName("Michael");
        studentBusinessObject.updateStudent(student);

        //获取学生
        studentBusinessObject.getStudent(0);
        System.out.println(student);
    }
}